<template>
  <div class="logo-wrap flex-box align-center">
    <img
      src="@/assets/logo.png"
      style="cursor: pointer"
      @click="router.push('/')"
      alt="logo"
    />
    <span class="logo-title">{{ SYSTEM_TITLE }}</span>
    <div
      v-if="showSide"
      class="icon-warp flex-box align-center justify-center"
      @click="clickHandler"
    >
      <el-icon v-if="isCollapse"><Fold /></el-icon>
      <el-icon v-else><Expand /></el-icon>
    </div>
    <teleport to="body">
      <div
        class="slider-mask"
        :class="{ 'is-open': isCollapse }"
        @click.self="clickHandler"
      >
        <Slider
          class="body-slider"
          :class="{ 'is-open': isCollapse }"
          style=""
        ></Slider>
      </div>
    </teleport>
  </div>
</template>
<style lang="scss" scoped>
@media screen and (max-width: 1000px) {
  .icon-warp {
    display: flex !important;
  }
}
.slider-mask {
  position: absolute;
  top: 0px;
  left: 0px;
  right: 0px;
  bottom: 0px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.3s linear, height 0s ease 0.3s;
  pointer-events: none;
  &.is-open {
    height: 100%;
    opacity: 1;
    transition: none;
    animation: antdDrawerFadeIn 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: auto;
  }
}
.body-slider {
  position: absolute;
  top: 0px;
  bottom: 0px;
  z-index: 10;
  display: block !important;
  box-shadow: 0px 0px 10px 5px #c1c1c1;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1),
    box-shadow 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  &.is-open {
    transform: translateX(0);
  }
}
.logo-wrap {
  width: 220px;
  min-width: 220px;
  color: #fff;
  img {
    height: 28px;
  }
  .logo-title {
    margin-left: 12px;
  }
  .icon-warp {
    margin-left: 20px;
    color: #fff;
    cursor: pointer;
    display: none;
    font-size: 32px;
  }
}
</style>
<script setup lang="ts">
import { Fold, Expand } from "@element-plus/icons-vue";
import Slider from "./Slider.vue";
import { SYSTEM_TITLE } from "@/config/global";
import { useRouter } from "vue-router";
import { useCollapse } from "@/hooks/layout/useCollapse";
import { useLayout } from "@/hooks/layout/useLayout";
const router = useRouter();
const { showSide } = useLayout();
const { isCollapse, clickHandler } = useCollapse();
</script>
